<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>组织架构 - 部门管理</title>


<link
	href='http://fonts.useso.com/css?family=Open+Sans:400,300,400italic,700'
	rel='stylesheet' type='text/css'>
<link href="./css/font-awesome.min.css" rel="stylesheet">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<link href="./css/jquery-confirm.css" rel="stylesheet">
<link href="./css/templatemo-style.css" rel="stylesheet">
<link rel="stylesheet" href="./css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script src="./js/jquery-1.11.2.min.js"></script>
<script src="./js/bootstrap.js"></script>
<script type="text/javascript" src="./js/jquery-confirm.js"></script>
<script type="text/javascript" src="./js/jquery.page.js"></script>
<!-- jQuery -->
<script type="text/javascript" src="./js/jquery.ztree.core-3.5.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->


<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body>
	<!-- Left column -->
	<div class="templatemo-flex-row">
		<div class="templatemo-sidebar">
			<header class="templatemo-site-header">
				<div class="square"></div>
				<h1>组织架构</h1>
			</header>

			<!-- Search box -->
			<form class="templatemo-search-form" role="search">
				<div class="input-group">
					<button type="submit" class="fa fa-search"></button>
					<input type="text" class="form-control" placeholder="Search"
						name="srch-term" id="srch-term">
				</div>
			</form>
			<div class="templatemo-content">
				<ul id="treeDemo" class="ztree"></ul>
			</div>
		</div>
		<!-- Main content -->
		<div class="templatemo-content col-1 light-gray-bg">
			<div class="templatemo-top-nav-container">
				<div class="row">
					<nav class="templatemo-top-nav col-lg-12 col-md-12">
						<ul class="text-uppercase">
							<li><a href="comhome">主页</a></li>
							<li><a id="dep" href="#" >部门查看</a></li>
							<li><a id="person" href="#">人员查看</a></li>
							<li><a href="logout">退出</a></li>
						</ul>
					</nav>
				</div>
			</div>
			<div class="templatemo-content-container">
				<!-- Modal -->

				<div class="templatemo-content-widget no-padding">
					<div class="panel panel-default table-responsive">

						<table 
							class="table table-striped table-bordered templatemo-user-table">
							<thead>
								<tr>
									<td><a href="#" class="white-text templatemo-sort-by">编号
											<span class="caret"></span>
									</a></td>
									<td><a  href="#" class="white-text templatemo-sort-by">名称<span
											class="caret"></span></a></td>
									<td><a href="#" class="white-text templatemo-sort-by">地址
											<span class="caret"></span>
									</a></td>
									<td><a href="#" class="white-text templatemo-sort-by">联系方式
											<span class="caret"></span>
									</a></td>
									<td><a href="#" class="white-text templatemo-sort-by">行政级别
											<span class="caret"></span>
									</a></td>
									<td><a href="#" class="white-text templatemo-sort-by">行政编码
											<span class="caret"></span>
									</a></td>
									<td><a href="#" class="white-text templatemo-sort-by">上级主管部门
											<span class="caret"></span>
									</a></td>
								</tr>
							</thead>
							<tbody id="orgTb">

							</tbody>
						</table>
					</div>
					<div class="tcdPageCode"></div>
				</div>
				<footer class="text-center">
					<p>Copyright &copy; 2015 宁波市政务云计算中心</p>
				</footer>
			</div>
		</div>
	</div>

	
	<!-- Templatemo Script -->
	<script type="text/javascript">
	
	
     var setting = {
      data: {
        simpleData: {
          enable: true
        }
      }
    }; 

    /* var zNodes =[
      { id:1, pId:0, name:"公安局", url:"orglist",target:"_self",open:true, iconOpen:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:11, pId:1, name:"交管局",  url:"orglist",target:"_self",open:true,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:12, pId:1, name:"交警局",  url:"orglist",target:"_self",open:true,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:121, pId:12, name:"支队1",  url:"personlist",target:"_self",open:false,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:122, pId:12, name:"支队2",  url:"personlist",target:"_self",open:false,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:1211, pId:121, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:1212, pId:121, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:1221, pId:122, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:1222, pId:122, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:2, pId:0, name:"工商局",  url:"orglist",target:"_self",open:true, iconOpen:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:21, pId:2, name:"科室1",  url:"personlist",target:"_self",open:false,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:22, pId:2, name:"科室2", url:"personlist",target:"_self",open:false,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:211, pId:21, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:212, pId:21, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:221, pId:22, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:222, pId:22, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:3, pId:0, name:"司法局",  url:"orglist",target:"_self",open:true, iconOpen:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:31, pId:3, name:"科室1", url:"personlist",target:"_self",open:false,icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:32, pId:3, name:"科室2",url:"personlist",target:"_self",open:false, icon:"./css/zTreeStyle/img/diy/1_open.png", iconClose:"./css/zTreeStyle/img/diy/1_close.png"},
      { id:311, pId:31, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:312, pId:31, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:321, pId:32, name:"人员1", icon:"./css/zTreeStyle/img/diy/user.png"},
      { id:322, pId:32, name:"人员2", icon:"./css/zTreeStyle/img/diy/user.png"},
    ]; */

    $(document).ready(function(){
       // alert("1");
    	  $.ajax(
 	    	    {url:"listcomindexorgtree", 
 	        	 dataType:"json",
 	        	 contentType: "application/x-www-form-urlencoded; charset=utf-8", 
 	        	 type:"POST",
 				success:function (data) {
 					$.fn.zTree.init($("#treeDemo"), setting, data);
 	        		   
 	    },
 	    error:function(){alert("出错啦！");}});

    
     $.ajax(
	    	    {url:"listorg", 
	        	 dataType:"json",
	        	 contentType: "application/x-www-form-urlencoded; charset=utf-8", 
	        	 type:"POST",
				success:function (data) {
		        	  // alert(data.length);
		        	   $.each(data, function(index, item) {
	   		        		  // alert(item["id"]);
	   		        		  // alert(index);
	   		        		  if(index<8){
	   		        		  var level="一级行政机构";
	   		        		  if(item["level"]==1) level="一级行政机构";
	   		        		  else if(item["level"]==2) level="二级行政机构";
	   		        		  else if(item["level"]==3) level="三级行政机构";
	   		        		  else if(item["level"]==4) level="四级行政机构";
	   		        		  else level="特殊行政机构";
	   		        		 var orgTb=document.getElementById("orgTb");
	   	 	        			var row=orgTb.insertRow(index);
	   	 	        			row.insertCell(0).innerHTML=item["id"];
	   	 	        			row.insertCell(1).innerHTML=item["name"];
	   	 	        			row.insertCell(2).innerHTML=item["address"];
	   	 	        			row.insertCell(3).innerHTML=item["phone"];
	   	 	        			row.insertCell(4).innerHTML=level;
	   	 	        			row.insertCell(5).innerHTML=item["sn"];
	   	 	        			row.insertCell(6).innerHTML=item["porg"];
	   		        		  }});  
		        		  if(data!=null&& data!=undefined && data!=""){	       
		        	$(".tcdPageCode").createPage({
        			pageCount:Math.ceil(data.length/8.0),
       				current:1,
        			backFn:function(p){
        				var tb=document.getElementById("orgTb");
        				var t=data.length-(Math.ceil(data.length/8.0)-1)*8;
							for(var i=7;i>=t;i--){
								for(var j=0;j<7;j++)
								tb.rows[i].cells[j].style.display="";
								}
        				 $.each(data, function(index, item) {
   		        		  // alert(item["id"]);
   		        		  if(index>=8*(p-1)&&index<8*p){
   		        			// alert(index);
   		        		  var level="一级行政机构";
   		        		  if(item["level"]==1) level="一级行政机构";
   		        		  else if(item["level"]==2) level="二级行政机构";
   		        		  else if(item["level"]==3) level="三级行政机构";
   		        		  else if(item["level"]==4) level="四级行政机构";
   		        		  else level="特殊行政机构";
   		        		  var row=index%8;
   		        		//  alert(row);
   		        		
   	 	        			//var row=orgTb.insertRow(index);
   	 	        		tb.rows[row].cells[0].innerHTML=item["id"];
   	 	        		tb.rows[row].cells[1].innerHTML=item["name"];
   	 	        		tb.rows[row].cells[2].innerHTML=item["address"];
   	 	        		tb.rows[row].cells[3].innerHTML=item["phone"];
   	 	    			tb.rows[row].cells[4].innerHTML=level;
   	 					tb.rows[row].cells[5].innerHTML=item["sn"];
   						tb.rows[row].cells[6].innerHTML=item["porg"];
   		        		  }
   		        		  }); 
        				 if(p==Math.ceil(data.length/8.0)){
 							var t=data.length-(p-1)*8;
 							for(var i=7;i>=t;i--){
 								for(var j=0;j<7;j++)
 								tb.rows[i].cells[j].style.display="none";
 								}
 							} 	       
        			}
   					 });
		        		  } else {
		        			  $.confirm({
		        				   keyboardEnabled: true,
		    	             	    //title: false, // hides the title.
		    	             	    content: '该部门下没有子部门!',
		    	             	    cancelButton: false, // hides the cancel button.
		    	             	    confirmButtonClass: 'btn-info',
		    	             	   autoClose: 'confirm|3000'
		    	             	});
			        		  }
	        		  
	    },
	    error:function(){alert("出错啦！");}});
    }); 
    $("#dep").click(function(){  
    	location.href = "comorglist?"+Math.random();
     });
    $("#person").click(function(){  
    	location.href = "compersonlist?"+Math.random();
     });
   </script>
</body>
</html>
